/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import connectivity.QueryManager;
import java.util.List;
import main.WinkelApplication;

/**
 *
 * @author 
 * Bart de Man * 
 * ________              _____     _________          ______  ___              
 * ___  __ )_____ _________  /_    ______  /____      ___   |/  /_____ _______ 
 * __  __  |  __ `/_  ___/  __/    _  __  /_  _ \     __  /|_/ /_  __ `/_  __ \
 * _  /_/ // /_/ /_  /   / /_      / /_/ / /  __/     _  /  / / / /_/ /_  / / /
 * /_____/ \__,_/ /_/    \__/      \__,_/  \___/      /_/  /_/  \__,_/ /_/ /_/ 
 * 
 */
public class Auth {
    
    private User user;
    
    public Auth() {
        
    }
    
    public boolean login(String username, String password) {
        //test
        QueryManager queryManager = WinkelApplication.getQueryManager();
        this.user = queryManager.getUser(username, password);
        
        //System.out.println(this.user);
        //System.out.println(this.user.getFirstname());
        if(this.user.getFirstname() == null) {
            
            return false;
        } else {
            //System.out.println("WORKS");
            WinkelApplication.setRoleID(this.user.getRoleId());
            return true;
        }
    }
    
    public void logOff() {
        WinkelApplication.getInstance().setRoleID(0);
        WinkelApplication.getInstance().showPanel(new view.Login());
    }
    
}
